<?php
namespace app\mysql\model;  //app 不能改
use think\Model;
use page;
class Test extends Model
// stock_table_info 这样的表名的驼峰命名法是TableInfo
{
 public function index(){
  echo 'model层';

 }
 /**
  * 新增数据
  */
 public function index2($name,$val){
 echo'服务 mysql/index/index2<br/> ';
// $sql = "insert into exam_student(name,age)values('xiaowang','285');"
 // dump($Model->execute($sql));
 
  // return $this->execute("insert into note_test ($name)values('xiaowang','2855')");
  return $this->execute("insert into note_test ($name)values($val)");
}


/**
  * 查询数据
  */
  public function index3(){
    echo'服务 mysql/index/index4<br/> ';
  return $this->query("select * from note_test");
  }

  /**
  * 查询数据 指定列
  */
  public function index4($name){
    echo'服务 mysql/index/index6<br/> ';
    
  return $this->query("select $name from note_test where 1");
  }

 /**
  * 查询数据 条件查询
  */
  public function index5($table,$where){
    echo'服务 mysql/index/index8<br/> ';
   
  return $this->query("select * from $table where $where");
  }


/**
  * 删除数据 返回 影响了多少条数据
  */
  public function index6($table,$where){
    echo'服务 mysql/index/index10<br/> ';
   
  return $this->execute("delete from $table where $where");
  }

/**
  * 修改数据  有条件 返回 影响了多少条数据
  */
  public function index7($table,$where,$up_data){
    echo'服务 mysql/index/index12<br/> ';
   
  return $this->execute("update $table set $up_data where $where");
  }


/**
  * 排序
  */
  public function index8($table,$name){
    echo'服务 mysql/index/index12<br/> ';
   
  return $this->query("select * from $table order by $name");
  }

/**
  * 排序
 */ 

 public function index9(){
    echo'服务 mysql/index/index8<br/> ';
   
  //  return $this->query("select * from note_listt where content like '%查询%' ");
  return $this->query("(select * from note_listt where content like '%字段%')union(select * from note_listt where content like '%查询%') ");
  }



 

}